# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=sipsak
pkgver=0.9.8.1
pkgrel=1
pkgdesc="SIP swiss army knife"
url="https://github.com/nils-ohlmeier/sipsak"
arch="all"
license="GPL-2.0-or-later"
makedepends="openssl-dev>3 c-ares-dev autoconf automake"
subpackages="$pkgname-dbg $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/nils-ohlmeier/sipsak/archive/$pkgver.tar.gz
	musl-fix-strcasestr.patch
	fix-aaaa-record-segfault.patch
	"

prepare() {
	default_prepare
	autoreconf --install
}

build() {
	# Fix for -fno-common being worked upstream
	# Issue:https://github.com/nils-ohlmeier/sipsak/issues/60
	# PR: https://github.com/nils-ohlmeier/sipsak/pull/61
	CFLAGS="$CFLAGS -fcommon" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info
	make
}

check() {
	./sipsak --version
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
b018a463e028b1e6cb31507957b7d2c1836341e2456d0df366edc12937d788ac548da6434d310917c9e32e12c02b7ae1462443c2461152ee3a3ee9cbf35d4618  sipsak-0.9.8.1.tar.gz
95fb13a5b3bc108544e6ac3a0c5e7a00890926df02b390c1fdb3e28a3cf4aa7ef3ffafd904cc4665547135fe45b412c4b676ae1c52d133d8deef62f062ac909f  musl-fix-strcasestr.patch
7bdad66145b37ca1039f01e4b523b1555bda8fc387e6b4745d53e89473c0b23d675b403b83ff9b59a75002fd26345699d71720e4c15fd419a56122dbc68c8682  fix-aaaa-record-segfault.patch
"
